/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dbTool;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
/**
 *
 * @author Admin
 */
public class mediaAction {
    public static String getItemForCombobox(){
        String combobox = "<select name='carName' >";
        String query = "select car.carID, typeCar.name from car left join typeCar on car.typeCarID = typeCar.typeCarID";
        Connection conn = null;
        PreparedStatement pstmt = null;
        myConnection cnn = new myConnection();
        ResultSet rs = null;
        try {
            conn = cnn.connect();
            pstmt = conn.prepareStatement(query);
            rs = pstmt.executeQuery();
            while(rs.next()){
                combobox += "<option value='" + rs.getInt("carID") + "' >"+ rs.getString("name") +" </option> ";
            }
        } catch (Exception ex) {
            System.out.println(ex);
        }
        combobox += "</select>";
        return combobox;
    }
}
